<template >
  <div class="new_header" >
    <div class="smart_container_rightBlock_top">
      <div class="logo" @click="handleGotoIndex">
        <img src="../../../assets/logo.png" alt="">
      </div>
      <div class="smart_rightBlock_block" v-if="langZh">
             <div v-if="!toDownLoad">
                <div class="lis" @click="handleGotoIndex" style="width: 55px;margin-left: 10px; text-decoration:underline;text-underline-position: under;">{{$setI18n('lang_br_home','首页')}}</div>
             </div>
             <div v-if="toDownLoad">
                 <div class="lis" @click="handleGotoIndex" style="width: 55px;margin-left: 10px;">{{$setI18n('lang_br_home','首页')}}</div>
             </div>
             <div class="lis" ><a href='https://pool.smartx.one/' >{{$setI18n('lang_pool','矿池')}}</a></div>
             <div class="lis" ><a href='https://smartx.one' >{{$setI18n('lang_text','文档')}}</a></div>
             <div class="lis" ><a href='https://alpha.smartx.one' >{{$setI18n('lang_wallet','钱包')}}</a></div>
             <div class="lis" ><a href='https://github.com/mangodager/smartx-dotnet' >{{$setI18n('lang_gitCode','Git源码')}}</a></div>
            <!--https://testnet.smartx.one/browser/downLoad -->
             <div v-if="toDownLoad">
                <div class="lis" @click="handleGotoDownLoad" style=" text-decoration:underline;text-underline-position: under;">{{$setI18n('lang_downLoadApp','下载')}}</div>
             </div>
             <div v-if="!toDownLoad">
                 <div class="lis" @click="handleGotoDownLoad" >{{$setI18n('lang_downLoadApp','下载')}}</div>
             </div>
             <div class="lis" ><a href='http://pos.smartx.one:8101/index.html' >{{$setI18n('lang_tool','开发者工具')}}</a></div>
             <div class="lis" ><a href='https://smartx.one/Whitepaper CN.pdf' style="margin-right: 15px">{{$setI18n('lang_whitePaper','白皮书')}}</a></div>
          <div class="lis picker-new" style="margin-left:2%;">
              <div class="arrow-down"><img class="language" src="../../../assets/images/newui/icon_laug.png" alt="">{{$setI18n('lang_selectLang','语言')}}</div>
              <div class="picker-block">
                  <div class="li" @click="handleClickChangeLang(0)">{{$setI18n('lang_chinese','中文')}}</div>
                  <div class="li" @click="handleClickChangeLang(1)">English</div>
                  <!-- <div class="li" @click="handleClickChangeLang(2)">Indonesia</div>
                  <div class="li" @click="handleClickChangeLang(3)">Philippines</div>
                  <div class="li" @click="handleClickChangeLang(4)">Russia</div> -->
              </div>
          </div>
      </div>
      <div class="smart_rightBlock_block" v-if="langEn">
          <div v-if="!toDownLoad">
              <div class="lisEn" @click="handleGotoIndex" style="width: 55px;margin-left: 10px; text-decoration:underline;text-underline-position: under;">{{$setI18n('lang_br_home','首页')}}</div>
          </div>
          <div v-if="toDownLoad">
              <div class="lisEn" @click="handleGotoIndex" style="width: 55px;margin-left: 10px;">{{$setI18n('lang_br_home','首页')}}</div>
          </div>
            <div class="lisEn" ><a href='https://pool.smartx.one/' >{{$setI18n('lang_pool','矿池')}}</a></div>
            <div class="lisEn" ><a href='https://smartx.one' >{{$setI18n('lang_text','文档')}}</a></div>
            <div class="lisEn" ><a href='https://alpha.smartx.one' >{{$setI18n('lang_wallet','钱包')}}</a></div>
            <div class="lisEn" ><a href='https://github.com/mangodager/smartx-dotnet' >{{$setI18n('lang_gitCode','Git源码')}}</a></div>
            <!--browser/downLoad -->
          <div v-if="toDownLoad">
              <div class="lisEn" @click="handleGotoDownLoad" style=" text-decoration:underline;text-underline-position: under;">{{$setI18n('lang_downLoadApp','下载')}}</div>
          </div>
          <div v-if="!toDownLoad">
              <div class="lisEn" @click="handleGotoDownLoad" >{{$setI18n('lang_downLoadApp','下载')}}</div>
          </div>
            <div class="lisEn" ><a href='http://pos.smartx.one:8101/index.html' >{{$setI18n('lang_tool','开发者工具')}}</a></div>
            <div class="lisEn" ><a href='https://smartx.one/Whitepaper CN.pdf' style="margin-right: 15px">{{$setI18n('lang_whitePaper','白皮书')}}</a></div>
            <div class="lis picker-new" style="margin-left:2%;">
                <div class="arrow-down"><img class="language" src="../../../assets/images/newui/icon_laug.png" alt="">{{$setI18n('lang_selectLang','语言')}}</div>
                <div class="picker-block">
                    <div class="li" @click="handleClickChangeLang(0)">{{$setI18n('lang_chinese','中文')}}</div>
                    <div class="li" @click="handleClickChangeLang(1)">English</div>
                    <!-- <div class="li" @click="handleClickChangeLang(2)">Indonesia</div>
                    <div class="li" @click="handleClickChangeLang(3)">Philippines</div>
                    <div class="li" @click="handleClickChangeLang(4)">Russia</div> -->
                </div>
            </div>
    </div>


      <div class="bottom_line"></div>
    </div>
    <div class="smart_container_rightBlock_top_phone">
      <div class="logo" @click="handleGotoIndex">
        <img src="../../../assets/logo.png" alt="">
      </div>
      <div class="smart_rightBlock_block">
        <!-- <div class="lis" @click="handleGotoIndex">{{$setI18n('lang_br_home','首页')}}</div>
        <div class="lis"><a href='https://smartx.one' target="_blank">{{$setI18n('lang_website','官网')}}</a></div>
        <div class="lis"><a href='https://#' target="_blank">{{$setI18n('lang_airdrop','空投')}}</a></div>
        <div class="lis" @click="handleGotoWallet">{{$setI18n('lang_br_blockTransaction','区块交易')}}</div>
        <div class="lis picker-new">
          <div class="arrow-down">Test NetWork</div>
          <div class="picker-block">
            <div class="li">Alpha Ver</div>
          </div>
        </div> -->
        <div></div>
        <div class="lis picker-new" style="margin-left:2%;margin-right: 60px">
          <Dropdown trigger="click"  >
              <a href="javascript:void(0)">
                 <img class="language" src="../../../assets/images/newui/icon_laug.png" alt="">{{$setI18n('lang_selectLang','语言')}}
              </a>
              <DropdownMenu slot="list" >
                  <DropdownItem>
                    <div @click="handleClickChangeLang(0)">{{$setI18n('lang_chinese','中文')}}</div>
                  </DropdownItem>
                  <DropdownItem>
                    <div @click="handleClickChangeLang(1)">English</div>
                  </DropdownItem>
                  <!-- <DropdownItem>
                    <div @click="handleClickChangeLang(2)">Indonesia</div>
                  </DropdownItem>
                  <DropdownItem>
                    <div @click="handleClickChangeLang(3)">Philippines</div>
                  </DropdownItem>
                  <DropdownItem>
                    <div @click="handleClickChangeLang(4)">Russia</div>
                  </DropdownItem> -->
              </DropdownMenu>
          </Dropdown>
        </div>

        <div >
          <Dropdown trigger="click" >
              <a href="javascript:void(0)">
                  <img class="menu" src="../../../assets/images/newui/menu.png" alt="">
              </a>
              <DropdownMenu slot="list" >
                  <DropdownItem>
                    <div @click="handleGotoIndex">{{$setI18n('lang_br_home','首页')}}</div>
                  </DropdownItem>
<!--               <div><a href="https://testnet.smartx.one/browser/downLoad?lang=ZH" >{{$setI18n('lang_downLoadApp','下载')}}</a></div>-->
                  <DropdownItem>
                      <div><a href='https://pool.smartx.one/' >{{$setI18n('lang_pool','矿池')}}</a></div>
                  </DropdownItem>
                  <DropdownItem>
                      <div><a href='https://smartx.one' >{{$setI18n('lang_text','文档')}}</a></div>
                  </DropdownItem>
                  <DropdownItem>
                      <div><a href='https://alpha.smartx.one' >{{$setI18n('lang_wallet','钱包')}}</a></div>
                  </DropdownItem>
                  <DropdownItem>
                      <div><a href='https://github.com/mangodager/smartx-dotnet' >{{$setI18n('lang_gitCode','Git源码')}}</a></div>
                  </DropdownItem>
                  <DropdownItem>
                      <div><a href='http://pos.smartx.one:8101/index.html' >{{$setI18n('lang_tool','开发者工具')}}</a></div>
                  </DropdownItem>
                  <DropdownItem>
                      <div><a href='https://smartx.one/Whitepaper CN.pdf'>{{$setI18n('lang_whitePaper','白皮书')}}</a></div>
                  </DropdownItem>
                  <DropdownItem>
                      <div @click="handleGotoDownLoad">{{$setI18n('lang_downLoadApp','下载')}}</div>
                  </DropdownItem>
              </DropdownMenu>
          </Dropdown>
        </div>
      </div>

      <div class="bottom_line"></div>
    </div>

<!--    <div style="width: 100%;height: 90px;">-->
<!--     <div class="max_width" style="height: 100%;margin-left: 31.4%">-->
<!--         <div class="topLink" >-->
<!--             <a  href="https://#">水龙头</a>-->
<!--         </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--        <div class="topLink" >-->
<!--            <a  href="https://#">水龙头</a>-->
<!--        </div>-->
<!--    </div>-->
<!--    </div>-->
  </div>

</template>

<script lang="ts">
import { Vue, Component, Prop, Watch } from "vue-property-decorator";

import { mapGetters, mapActions } from "vuex";

import Utils from "@/utils/index";



@Component
export default class TopNav extends Vue {
  /** 用户输入的地址; */
  //private addressParms:String = '';

  // /** 头部筛选下拉框 */
  // private selectAll:Array<object> = [{
  //     text: '全部筛选',
  //     index: 0,
  //     state: 1
  // },{
  //     text: '地址',
  //     index: 1,
  //     state: 0
  // },{
  //     text: '主板',
  //     index: 2,
  //     state: 0
  // },{
  //     text: '交易',
  //     index: 3,
  //     state: 0
  // }]

  /** 切换下拉框 */
  // private handleClickSelect(_index:number){

  //     let _emtry:Array<object> = [];

  //     this.selectAll.forEach(_item=>{

  //        if(_index == _item['index']){

  //           _item['state'] = 1;

  //        }else{

  //           _item['state'] = 0;
  //        }
  //     });

  //     this.selectAll = _emtry.concat(this.selectAll);
  // }

  /** 跳到对应的钱包地址 */
  // private handleGotoAddressInfor():void{

  //     this.$router.push({ path: '/browser/addressInformation', query:{ 'address': String(this.addressParms)}});
  // }

  private langZh:boolean=true;
  private langEn:boolean=false;
  private lang = "ZH";
  private toDownLoad = false;

  /** 刷新本页 */
  private handleGotoIndex(): void {
    this.$router.push({ path: "/browser?lang="+this.lang });

    // window.setTimeout(() => {
    //   window.location.reload();
    // }, 600);
  }

  /** 下载页面*/
  private handleGotoDownLoad(): void {
    this.$router.push({ path: "/browser/downLoad?lang="+this.lang });

    // window.setTimeout(() => {
    //   window.location.reload();
    // }, 600);
  }

  /** 跳钱包登录页面 */
  private handleGotoWallet(): void {
    this.$router.push({ path: "/browser/transactionRecord" });
  }

  private mounted(): void {
    // this.handleClickChangeLang(0);
    let _lang=Utils['getUrlParam']('lang');
    this.lang = _lang || "ZH";
    this.$i18n["locale"] = this.lang==='ZH'?"zh-CN":"en-US";
    this.langZh = this.lang==='ZH';
    this.langEn = this.lang==='EN';
    this.toDownLoad = window.location.href.indexOf("downLoad")!==-1;
  }

  /** 切换语言 */
  private handleClickChangeLang(_type): void {
    if (_type == 0) {
      this.$i18n["locale"] = "zh-CN";
      this.langZh=true;
      this.langEn=false;
      this.lang = 'ZH';
      // console.log("网址是这个==》"+window.location.href);
    } else if (_type == 1) {
      this.$i18n["locale"] = "en-US";
      this.langZh=false;
      this.langEn=true;
      this.lang = 'EN';
      // console.log("网址是这个==》"+window.location.href);
    } else if (_type == 2) {
      this.$i18n["locale"] = "en-ID";
    } else if (_type == 3) {
      this.$i18n["locale"] = "en-PH";
    } else if (_type == 4) {
      this.$i18n["locale"] = "ru-RU";
    }

    Utils["setSessionStorage"]("lang", this.$i18n["locale"]);

    this.$emit("changeLangEvent", this.$i18n["locale"]);
  }
}
</script>

<style lang="scss">
@import "topNav";
</style>
